package formula.web;

import java.io.Serializable;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;

import org.slf4j.LoggerFactory;

@SuppressWarnings("serial")
@ManagedBean
@ViewScoped
public class LevelsView implements Serializable {

	private final org.slf4j.Logger logger = LoggerFactory.getLogger(getClass());

	@ManagedProperty(value = LevelHome.EL_NAME)
	LevelHome levelHome;
	@ManagedProperty(value = LevelsHome.EL_NAME)
	LevelsHome levelsHome;
	private boolean editMode = false;

	public void cancelEditLevel() {
		levelHome.clear();
		this.editMode = false;
	}

	public void deleteLevel() {
		levelHome.doDelete();
		levelsHome.clear();
		this.editMode = false;
	}

	public void updateLevel() {
		levelHome.doMerge();
		levelsHome.clear();
		this.editMode = false;
	}

	public void editNewLevel() {
		levelHome.clear();
		this.editMode = true;
	}

	public void setEditLevelById(Long _levelId) {
		levelHome.setLevelId(_levelId);
		editMode = true;
	}

	// then below : simple setters and getters
	public void setLevelHome(LevelHome _levelHome) {
		this.levelHome = _levelHome;
	}

	public boolean isEditMode() {
		return editMode;
	}

	public void setEditMode(boolean _editMode) {
		editMode = _editMode;
	}

	public void setLevelsHome(LevelsHome _levelsHome) {
		levelsHome = _levelsHome;
	}
}
